﻿<Window x:Class="eDirectory.WPF.Customer.View.CustomerView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"        
        Title="Customer View" Height="400" Width="400" WindowStartupLocation="CenterScreen">
    <Grid Name="MainLayout">
        <Grid.RowDefinitions>
            <RowDefinition Name="CustomerSection" Height="Auto"/>
            <RowDefinition Name="CollectionSection" />
        </Grid.RowDefinitions>
        <GroupBox Header="New Customer" Margin="5" Padding="5" Grid.Row="0" IsEnabled="{Binding Path=Model.IsEnabled}">
            <Grid Name="NewCustomer">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                
                <Label Grid.Column="0" Grid.Row="0">First Name</Label>
                <TextBox Grid.Column="0" Grid.Row="1" Text="{Binding Path=Model.NewCustomerOperation.FirstName, Mode=TwoWay}"></TextBox>

                <Label Grid.Column="1" Grid.Row="0">Last Name</Label>
                <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=Model.NewCustomerOperation.LastName, Mode=TwoWay}"></TextBox>

                <Label Grid.Column="2" Grid.Row="0">Telephone</Label>
                <TextBox Grid.Column="2" Grid.Row="1" Text="{Binding Path=Model.NewCustomerOperation.Telephone, Mode=TwoWay}"></TextBox>

                <Button Grid.Column="1" Grid.Row="2" Padding="5" Margin="5" Command="{Binding SaveCommand}">Save</Button> 
            </Grid>
        </GroupBox>
        <GroupBox Header="List of Customers" Margin ="5" Padding="5" Grid.Row="1">
            <Grid Name="ListOfCustomers">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <tk:DataGrid Grid.Row="0" Name="CustomerGrid" 
                             AutoGenerateColumns="False" 
                             CanUserAddRows="False" 
                             VerticalScrollBarVisibility="Visible"
                             CanUserReorderColumns="False"
                             VerticalAlignment="Top"
                             ItemsSource="{Binding Path=Model.CustomerList}">                    
                    <tk:DataGrid.Columns>
                        <tk:DataGridTextColumn Header="Customer Id" Binding="{Binding Path=Id, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="First Name" Binding="{Binding Path=FirstName, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Last Name" Binding="{Binding Path=LastName, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Telephone" Binding="{Binding Path=Telephone, Mode=OneWay}"/>
                    </tk:DataGrid.Columns>
                </tk:DataGrid>
                <Button Grid.Row="1" Padding="5" Margin="5" Command="{Binding RefreshCommand}" IsEnabled="{Binding Path=Model.IsEnabled}">Refresh</Button>
            </Grid>
        </GroupBox>
    </Grid>
</Window>
